package com.xbs.controller.hitchhiking;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.controller.enterprise.DateJsonValueProcessor;
import com.xbs.entity.CommonOrderEntity;
import com.xbs.entity.EmployeeEntity;
import com.xbs.entity.HitchOrderAdminEntity;
import com.xbs.entity.TimeEntity;
import com.xbs.service.hitchhiking.EmpAdminService;
import com.xbs.service.hitchhiking.HitchOrderAdminService;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;
/**
 * 第一次修改顺风车的订单
 * 取车时操作顺风车订单
 * @author dell
 */
@WebServlet("/backstage/xghoajax1")
public class XgHitchOrderAjaxServlet extends BaseServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		HitchOrderAdminService hoas = new HitchOrderAdminService();
		
		/**
		 * 根据订单编号进行取车修改
		 */
		CommonOrderEntity coe = new CommonOrderEntity();
		TimeEntity te = new TimeEntity();
		String time1 = req.getParameter("time1");
		Timestamp gettime = new Timestamp(System.currentTimeMillis());
		gettime = Timestamp.valueOf(time1);
		te.setTime_fact_get(gettime);
		String ddid = req.getParameter("ddid");
		coe.setCo_id(ddid);
		
		List<CommonOrderEntity> coelst = hoas.selOrderByGet(coe);
		int row = hoas.updateGetTime(te);
		
		JsonConfig jsonConfig = new JsonConfig();   
		jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);   
		jsonConfig.registerJsonBeanProcessor(java.sql.Date.class, new DateJsonValueProcessor());  
		jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    
		//JSONArray jsonArray = JSONArray.fromObject(xgemp.getIst(),jsonConfig);
		JSONObject obj = null;
		if(coelst.size()>0){
			obj =JSONObject.fromObject(coelst.get(0),jsonConfig); 
		}
	
		resp.getWriter().print(obj);
	}
}
